package com.yoouce.patchmng.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created by Scott.Lee on 15-10-9.
 */
public class StreamGobbler extends Thread
{
    
    private InputStream in;
    
    private static StringBuffer result = new StringBuffer();
    
    public StreamGobbler(InputStream in)
    {
        this.in = in;
    }
    
    public void run()
    {
        
        String str;
        BufferedReader inline = new BufferedReader(new InputStreamReader(in));
        try
        {
            while ((str = inline.readLine()) != null)
            {
                result = result.append(str).append("\n");
            }
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
    
    public StringBuffer getResult()
    {
        return result;
    }
}
